﻿package com.javaPattern.Mediator;

public class MediatorTest {

	public static void main(String[] args) {
		// 生成中介者 并注入到各个Colleague对象中
		Mediator mediator = new ConcreteMediator();
		Colleague colleague1 = new Colleague1(mediator);
		Colleague colleague2 = new Colleague2(mediator);
		Colleague colleague3 = new Colleague3(mediator);

		// 注册对象到中介
		mediator.addCollegue(colleague1);
		mediator.addCollegue(colleague2);
		mediator.addCollegue(colleague3);

		// Colleague1 触发行为
		colleague1.sendMsg("嗨，大家好！");
		System.out.println();
		// Colleague2 触发行为
		colleague2.sendMsg("很高兴见到你！");
		System.out.println();
		// Colleague3 触发行为
		colleague3.sendMsg("我们一起玩游戏吧！");
		System.out.println();

	}
}
